<script type="text/javascript">
tinyMCE.init({
		// General options
		mode : "exact",
		elements : "elm2",
		theme : "advanced",
		skin : "o2k7",
		plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave",

		// Theme options
		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		// Replace values for the template plugin
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});
</script>

<?php
$id = $_REQUEST['_d'];
$page = $_REQUEST['page'];

if($_REQUEST['_a'] != "u" && $_REQUEST['_a'] != "d")
{
$q = mysql_fetch_array(mysql_query("select * from blog where Id='$id'"));
?>
<?php
if($_REQUEST['_s'] == 1)
{ ?>
	<table align="center" border="0">
	<tr>
    	<td align="center"><div class="sucmsg"><img src="images/information.png" align="absmiddle" />&nbsp;Updated Successfully</div></td>
    </tr>    
    </table>
<?php } ?>

<form name="up" action="index.php?tc=blog_view&_d=<?php echo  $id;?>&page=<?php echo  $page;?>&_a=u" method="post">
<table width="99%" align="center" border="0"  class="list" cellpadding="5">
<thead>
<tr>
	<td colspan="2" align="left">
        <div style="float:left">Blog</div>
        <div style="float:right"><a href="index.php?tc=blog&page=<?php echo  $page;?>">Back</a></div>
    </td>
</tr>
</thead>
<tr>
	<td align="right" width="150">Title</td>
    <td align="left"><input type="text" name="title" value="<?php echo  $q['title'];?>"  /></td>
</tr>
<tr>
  <td align="right" width="150">Blog Details</td>
  <td align="left"><textarea name="news" id="elm2" cols="80" rows="5"><?php echo  $q["comments"];?></textarea></td>
</tr>
<tr>
  <td align="right" width="150">Status</td>
  <td align="left">
    <input class="text" name="authorised" type="radio" value=1 <?php if($q["status"] == 1) echo "checked";?> />&nbsp;Active&nbsp;&nbsp;
    <input class="text" name="authorised" type="radio" value=0 <?php if($q["status"] == 0) echo "checked";?> />&nbsp;Deactive
    </td>
</tr> 
<tr>
  <td colspan="2" style="padding-left:155px;">
    <input type="submit" value="Update" >&nbsp;&nbsp;
    
    </td>
</tr>        
</table>   
</form> 
<?php
}

if($_REQUEST['_a']=="u")
{
	$title = $_POST['title'];
	$news = addslashes($_POST['news']);
	$authorised = $_POST['authorised'];
	
	mysql_query("update blog set title='$title', comments='$news', status='$authorised' where id='$id'");
	//header("location:index.php?tc=blog_view&_d=$id&page=$page&_s=1");
	echo "<script>window.location='index.php?tc=blog_view&_d=$id&page=$page&_s=1'</script>";
}
if($_REQUEST['_a']=="d")
{
	mysql_query("delete from blog where id='$id'");
	//header("location:index.php?tc=blog&page=$page&_s=2");
	echo "<script>window.location='index.php?tc=blog&page=$page&_s=2'</script>";
}
?>